package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.MomentForm;
import com.springboot.cloud.demos.entity.po.Moment;
import com.springboot.cloud.demos.ribbon.service.MomentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class MomentController {

    @Autowired
    private MomentService momentService;


    @PostMapping("/moment")
    public Result<Moment> add(@RequestBody MomentForm momentForm) {
        return momentService.save(momentForm);
    }

    @RequestMapping(value = "/moment/{id}", method = RequestMethod.GET)
    Result<Moment> get(@PathVariable String id) {
        return momentService.get(id);
    }

    @RequestMapping(value = "/moment/getMomentMap", method = RequestMethod.GET)
    Result getMomentMap(String id) {
        return momentService.getMomentMap(id);
    }

    @RequestMapping(value = "/moment/{id}", method = RequestMethod.DELETE)
    Result delete(@PathVariable String id) {
        return momentService.delete(id);
    }

    @RequestMapping(value = "/moment/list/{userId}", method = RequestMethod.GET)
    Result list(@PathVariable(value = "userId") String userId, Integer type, Integer pageNo, Integer pageSize) {
        return momentService.list(userId, type, pageNo, pageSize);
    }

    @RequestMapping(value = "/moment/followList", method = RequestMethod.GET)
    Result followList(String userId, Integer sex, Integer real, Integer pretty, Integer pageNo, Integer pageSize) {
        return momentService.followList(userId, sex, real, pretty, pageNo, pageSize);
    }

    @RequestMapping(value = "/moment/recommendList", method = RequestMethod.GET)
    Result recommendList(String id, Integer sex, Integer real, Integer pretty, Integer pageNo, Integer pageSize) {
        return momentService.recommendList(id, sex, real, pretty, pageNo, pageSize);
    }

    @RequestMapping(value = "/moment/broadcastList", method = RequestMethod.GET)
    Result broadcastList(Integer sex, Integer real, Integer pretty, Integer type, Integer pageNo, Integer pageSize) {
        return momentService.broadcastList(sex, real, pretty, type, pageNo, pageSize);
    }

    @RequestMapping(value = "/moment/nearbyList", method = RequestMethod.GET)
    Result nearbyList(Integer sex, Integer real, Integer pretty, float longitude, float latitude, Integer pageNo, Integer pageSize) {
        return momentService.nearbyList(sex, real, pretty, longitude, latitude, pageNo, pageSize);
    }

    @RequestMapping(value = "/moment/next", method = RequestMethod.GET)
    Result next(String momentId) {
        return momentService.next(momentId);
    }

    @RequestMapping(value = "/moment/prev", method = RequestMethod.GET)
    Result prev(String momentId) {
        return momentService.prev(momentId);
    }
}
